// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class titleGroup extends cc.Component {

    @property(cc.Label)
    labList : cc.Label[] = [];

    @property(cc.Node)
    masterNode : cc.Node = null;

    @property(cc.Node)
    petNode : cc.Node = null;

    @property({type : cc.Component.EventHandler,displayName : "触发事件"})
    toolEvent : cc.Component.EventHandler[] = [];

    action1(){
        cc.tween(this.labList[0].node).by(0.3,{
            position : cc.v2(-500,0)
        }).start();
    }

    action2(){
        this.masterNode.active = true;
        this.petNode.active = false;
        cc.tween(this.labList[0].node).by(0.8,{
            position : cc.v2(500,0)
        }).call(()=>{
            this.scheduleOnce(()=>{
                cc.tween(this.labList[1].node).by(0.8,{
                    position : cc.v2(-500,0)
                }).call(()=>{
                    this.scheduleOnce(()=>{
                        cc.tween(this.labList[1].node).by(0.3,{
                            position : cc.v2(0,100)
                        }).start();

                        cc.tween(this.labList[2].node).by(0.8,{
                            position : cc.v2(-500,0)
                        }).call(()=>{
                            this.scheduleOnce(()=>{
                                cc.tween(this.labList[1].node).by(0.3,{
                                    position : cc.v2(0,100)
                                }).start();

                                cc.tween(this.labList[2].node).by(0.3,{
                                    position : cc.v2(0,100)
                                }).start();
                                cc.tween(this.labList[3].node).by(0.8,{
                                    position : cc.v2(-700,0)
                                }).call(()=>{
                                    this.scheduleOnce(()=>{
                                        cc.tween(this.labList[1].node).by(0.3,{
                                            position : cc.v2(500,0)
                                        }).start();

                                        cc.tween(this.labList[2].node).by(0.3,{
                                            position : cc.v2(500,0)
                                        }).start();

                                        cc.tween(this.labList[3].node).by(0.3,{
                                            position : cc.v2(600,0)
                                        }).call(()=>{
                                            this.labList[4].node.active = true;
                                            cc.Component.EventHandler.emitEvents(this.toolEvent, []);
                                        }).start();
                                    },1)
                                }).start();
                            },0.8)
                        }).start();
                    },0.8)
                }).start();
            },0.8)
        }).start();
    }
    // update (dt) {}
}
